package com.jackstraw.jack_base.datasource.database.generator.util;


import org.apache.commons.configuration2.PropertiesConfiguration;
import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
import org.apache.commons.configuration2.builder.fluent.Configurations;
import org.apache.commons.configuration2.ex.ConfigurationException;

public class MyBatisUtil {


    /**
     * 获取配置信息
     */
    public static org.apache.commons.configuration2.Configuration getConfig() {
        PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();

        Configurations configs = new Configurations();
        // setDefaultEncoding是个静态方法,用于设置指定类型(class)所有对象的编码方式。
        // 本例中是PropertiesConfiguration,要在PropertiesConfiguration实例创建之前调用。
        FileBasedConfigurationBuilder.setDefaultEncoding(PropertiesConfiguration.class, "UTF-8");
        try {
            propertiesConfiguration = configs.properties(MyBatisUtil.class.getClassLoader().getResource("generator.properties"));
        } catch (ConfigurationException e) {
            throw new RuntimeException(e);
        }

        return propertiesConfiguration;
    }


}
